package o;

import android.content.Context;
import android.view.MenuItem;
import android.view.SubMenu;
import java.util.Iterator;
import java.util.Map;

abstract class bf<T> extends bh<T> {
    final Context ˊ;
    private Map<gk, MenuItem> ˋ;
    private Map<gj, SubMenu> ˏ;

    bf(Context context, T t) {
        super(t);
        this.ˊ = context;
    }

    final MenuItem ˎ(MenuItem menuItem) {
        if (!(menuItem instanceof gk)) {
            return menuItem;
        }
        gk gkVar = (gk) menuItem;
        if (this.ˋ == null) {
            this.ˋ = new ds();
        }
        MenuItem menuItem2 = (MenuItem) this.ˋ.get(menuItem);
        if (menuItem2 != null) {
            return menuItem2;
        }
        menuItem2 = bq.ॱ(this.ˊ, gkVar);
        this.ˋ.put(gkVar, menuItem2);
        return menuItem2;
    }

    final SubMenu ˏ(SubMenu subMenu) {
        if (!(subMenu instanceof gj)) {
            return subMenu;
        }
        gj gjVar = (gj) subMenu;
        if (this.ˏ == null) {
            this.ˏ = new ds();
        }
        SubMenu subMenu2 = (SubMenu) this.ˏ.get(gjVar);
        if (subMenu2 != null) {
            return subMenu2;
        }
        subMenu2 = bq.ॱ(this.ˊ, gjVar);
        this.ˏ.put(gjVar, subMenu2);
        return subMenu2;
    }

    final void ॱ() {
        if (this.ˋ != null) {
            this.ˋ.clear();
        }
        if (this.ˏ != null) {
            this.ˏ.clear();
        }
    }

    final void ˊ(int i) {
        if (this.ˋ != null) {
            Iterator it = this.ˋ.keySet().iterator();
            while (it.hasNext()) {
                if (i == ((MenuItem) it.next()).getGroupId()) {
                    it.remove();
                }
            }
        }
    }

    final void ˋ(int i) {
        if (this.ˋ != null) {
            Iterator it = this.ˋ.keySet().iterator();
            while (it.hasNext()) {
                if (i == ((MenuItem) it.next()).getItemId()) {
                    it.remove();
                    return;
                }
            }
        }
    }
}
